package com.itheima.sparkml.exercise

import org.apache.spark.mllib.regression.LabeledPoint
import org.apache.spark.mllib.util.MLUtils
import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object _3LibSVMLoaderCore {
  def main(args: Array[String]): Unit = {
    val sparkConf=new SparkConf().setAppName("_3LibSVMLoaderCore").setMaster("local[*]")
    val sc=new SparkContext(sparkConf)
    sc.setLogLevel("WARN")
    val dataPath="D:\\test\\data\\iris_libsvm.txt"
    val unit: RDD[LabeledPoint] = MLUtils.loadLibSVMFile(sc,dataPath)
    //unit.foreach(println(_))
    val Array(train,test)=unit.randomSplit(Array(0.8,0.2),123L)
    train.foreach(println(_))
    println("===============")
    test.foreach(println(_))
    sc.stop()
  }
}
